Skip to main content

Embedding Banners

Embed a customizable banner in your application.

SwiftUI

Adding the NudgeAppComponentView

To integrate the NudgeAppComponentView into your SwiftUI layout, add it to a container view such as VStack, HStack, or ZStack:

NudgeAppComponentView(id: "widget_id")
.fixedSize(horizontal: false, vertical: true)

Note: It is strongly recommended to use the .fixedSize() modifier to avoid size inconsistencies.


UIKit

Using Storyboard

  1. Drag an empty UIView onto your storyboard and set the desired size constraints.

  2. Select the view, and from the class inspector, assign it to NudgeAppComponent.

  3. Create an outlet for the view in your class.

  4. Assign an id to the view:

    view.id = "widget_id"

Using a Custom View

  1. Initialize the NudgeAppComponent class:

    let nudgeAppComponent = NudgeAppComponent()
  2. Assign an id:

    nudgeAppComponent.id = "widget_id"
  3. Add it to the desired subview:

    self.view.addSubview(nudgeAppComponent)
  4. Apply Auto Layout constraints to fit your view hierarchy:

    nudgeAppComponent.translatesAutoresizingMaskIntoConstraints = false

    NSLayoutConstraint.activate([
    nudgeAppComponent.leadingAnchor.constraint(equalTo: view.leadingAnchor),
    nudgeAppComponent.trailingAnchor.constraint(equalTo: view.trailingAnchor),
    nudgeAppComponent.centerXAnchor.constraint(equalTo: view.centerXAnchor),
    nudgeAppComponent.centerYAnchor.constraint(equalTo: view.centerYAnchor)
    ])